package com.hq.ims.data.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.hq.ims.data.entityenum.EnumGroupType;
import com.hq.ims.data.vo.PermissionGroupMapstruct;
import com.hq.mybatis.base.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
* @author 蒋柏平
* @since 20240929
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Alias("PermissionGroup")
@TableName(value = "permission_group")
@ApiModel(value = "角色或权限分类", description = "角色或权限分类")
public class PermissionGroup extends BaseModel<PermissionGroup> implements Serializable {

    @ApiModelProperty(value = "id标识")
    @TableId(value = "permission_group_id",type = IdType.ASSIGN_UUID)
    private String permissionGroupId;

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "create_date_time", fill = FieldFill.INSERT)
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createDateTime;

    @ApiModelProperty(value = "更新时间")
    @TableField(value = "update_date_time", fill = FieldFill.INSERT_UPDATE)
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateDateTime;

    @ApiModelProperty(value = "创建人名称")
    @TableField(value = "create_user_name", fill = FieldFill.INSERT)
    private String createUserName;

    @ApiModelProperty(value = "更新人名称")
    @TableField(value = "update_user_name", fill = FieldFill.INSERT_UPDATE)
    private String updateUserName;

    @ApiModelProperty(value = "组名称")
    @TableField(value = "group_name")
    private String groupName;

    @ApiModelProperty(value = "排序")
    @TableField(value = "sort_number")
    private Integer sortNumber;

    @ApiModelProperty(value = "组类别")
    @TableField(value = "group_type")
    private EnumGroupType groupType;

    @ApiModelProperty(value = "所属公司id")
    @TableField(value = "company_id")
    private String companyId;

    @ApiModelProperty(value = "是否允许编辑")
    @TableField(value = "is_allow_edit")
    private Boolean isAllowEdit;

    @ApiModelProperty(value = "是否删除")
    @TableField(value = "is_del")
    @TableLogic
    private Boolean isDel;

    @ApiModelProperty(value = "版本号")
    @TableField(value = "version")
    @Version
    private Integer version;

    public PermissionGroupMapstruct.PermissionGroupRowAuthVo auth(){
        PermissionGroupMapstruct.PermissionGroupRowAuthVo auth = new PermissionGroupMapstruct.PermissionGroupRowAuthVo(this);
        return auth;
    }

}
